package org.mikeliu;

import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;

import org.mikeliu.massbox.Massbox;

public class Main {
    private static final Map<String, String> nestedProgramName = new HashMap<>();
    static {
        nestedProgramName.put("ls", "org.mikeliu.ls.List");
    }

    private Main() {
    }

    public static void main(String[] args) throws NoSuchMethodException, SecurityException, ClassNotFoundException,
            IllegalAccessException, InvocationTargetException {
        if (args.length >= 1) {
            if (nestedProgramName.containsKey(args[0])) {
                Class<?> className = Class.forName(nestedProgramName.get(args[0]));
                className.getMethod("main", args.getClass()).invoke(null, (Object) args);
            }
        } else if (args.length >= 2) {
            if (nestedProgramName.containsKey(args[1])) {
                Class<?> className = Class.forName(nestedProgramName.get(args[1]));
                className.getMethod("main", args.getClass()).invoke(null, (Object[]) args);
            }
        } else {
            Massbox.main(args);
        }

    }
}
